home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / System Extensions / Macintosh Drag and Drop 1.1.1 / Demo Applications / DragText Sources / cursor.c next >
Encoding:
C/C++ Source or Header  |  1993-06-21  |  1.7 KB  |  86 lines  |  [TEXT/KAHL]

  1. /*
  2.  *
  3.  *        cursor.c
  4.  *
  5.  *        Cursor handling routines.
  6.  *        
  7.  *
  8.  *        Author:        Rob Johnston
  9.  *        Date:        Friday, Janurary 17, 1992
  10.  *
  11.  *        Copyright © 1992 Apple Computer, Inc.
  12.  *
  13.  */
  14.  
  15. #include "globals.h"
  16. #include "prototypes.h"
  17. #include "resources.h"
  18.  
  19.  
  20. short AdjustCursor(Point theLoc, RgnHandle theRgn)
  21.  
  22. {    WindowPtr    theWindow;
  23.     Document    *theDocument;
  24.     RgnHandle    arrowRgn, iBeamRgn, hiliteRgn;
  25.     Rect        theRect;
  26.     Point        thePoint;
  27.     MenuHandle    theMenu;
  28.     Str255        theName;
  29.  
  30.     if (gInBackground)
  31.         return;
  32.  
  33.     arrowRgn = NewRgn();
  34.     SetRectRgn(arrowRgn, -32767, -32767, 32767, 32767);
  35.  
  36.     if ((theWindow = FrontWindow()) && (theDocument = IsDocumentWindow(theWindow))) {
  37.         SetPort(theWindow);
  38.         iBeamRgn = NewRgn();
  39.         hiliteRgn = NewRgn();
  40.  
  41.         theRect = (**(theDocument->theTE)).viewRect;
  42.         LocalToGlobal(&(theRect.top));
  43.         LocalToGlobal(&(theRect.bottom));
  44.         RectRgn(iBeamRgn, &theRect);
  45.  
  46.         CopyRgn(theDocument->hiliteRgn, hiliteRgn);
  47.         thePoint.h = thePoint.v = 0;
  48.         LocalToGlobal(&thePoint);
  49.         OffsetRgn(hiliteRgn, thePoint.h, thePoint.v);
  50.  
  51.         DiffRgn(arrowRgn, hiliteRgn, arrowRgn);
  52.         DiffRgn(arrowRgn, iBeamRgn, arrowRgn);
  53.  
  54.         DiffRgn(iBeamRgn, hiliteRgn, iBeamRgn);
  55.  
  56.         if (PtInRgn(theLoc, iBeamRgn)) {
  57.             SetCursor(*GetCursor(iBeamCursor));
  58.             CopyRgn(iBeamRgn, theRgn);
  59.         } else if (PtInRgn(theLoc, hiliteRgn)) {
  60.             SetCursor(&qd.arrow);
  61.             CopyRgn(hiliteRgn, theRgn);
  62.         } else {
  63.             SetCursor(&qd.arrow);
  64.             CopyRgn(arrowRgn, theRgn);
  65.         }
  66.         
  67.         DisposeRgn(iBeamRgn);
  68.         DisposeRgn(hiliteRgn);
  69.     } else {
  70.         SetCursor(&qd.arrow);
  71.         CopyRgn(arrowRgn, theRgn);
  72.     }
  73.  
  74.     DisposeRgn(arrowRgn);
  75. }
  76.  
  77.  
  78. short GetGlobalMouse(Point *theLoc)
  79.  
  80. {    EventRecord        theEvent;
  81.     
  82.     OSEventAvail(0, &theEvent);
  83.     *theLoc = theEvent.where;
  84. }
  85.  
  86.